package com.ruoyi.system.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TOrdersMapper;
import com.ruoyi.system.domain.TOrders;
import com.ruoyi.system.service.ITOrdersService;

/**
 * 订单Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-24
 */
@Service
public class TOrdersServiceImpl implements ITOrdersService
{
    @Autowired
    private TOrdersMapper tOrdersMapper;

    /**
     * 查询订单
     *
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    public TOrders selectTOrdersById(Long orderId)
    {
        return tOrdersMapper.selectTOrdersById(orderId);
    }

    /**
     * 查询订单列表
     *
     * @param tOrders 订单
     * @return 订单
     */
    @Override
    public List<TOrders> selectTOrdersList(TOrders tOrders)
    {
        return tOrdersMapper.selectTOrdersList(tOrders);
    }

    /**
     * 新增订单
     *
     * @param tOrders 订单
     * @return 结果
     */
    @Override
    public int insertTOrders(TOrders tOrders)
    {
        tOrders.setCreateTime(DateUtils.getNowDate());
        return tOrdersMapper.insertTOrders(tOrders);
    }

    /**
     * 修改订单
     *
     * @param tOrders 订单
     * @return 结果
     */
    @Override
    public int updateTOrders(TOrders tOrders)
    {
        tOrders.setUpdateTime(DateUtils.getNowDate());
        return tOrdersMapper.updateTOrders(tOrders);
    }

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteTOrdersByIds(Long[] ids)
    {
        return tOrdersMapper.deleteTOrdersByIds(ids);
    }

    /**
     * 删除订单信息
     *
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deleteTOrdersById(Long id)
    {
        return tOrdersMapper.deleteTOrdersById(id );
    }

    @Override
    public List<TOrders> ordersListByUserId(Long userId,Long status) {
        return tOrdersMapper.ordersListByUserId(userId,status);
    }

    @Override
    public List<TOrders> getOneDay() {
        return  tOrdersMapper.getOneDay();
    }

    @Override
    public Integer countOrderStatusNum(int oederStatus) {
        return tOrdersMapper.countOrderStatusNum(oederStatus);
    }

    @Override
    public BigDecimal sumOrderAmount() {
        return tOrdersMapper.sumOrderAmount();
    }

    @Override
    public List<TOrders> selectDeliveryList() {
        return tOrdersMapper.selectDeliveryList();
    }

    @Override
    public List<TOrders> selectReceivedList(Long userId) {
        return tOrdersMapper.selectReceivedList(userId);
    }

    @Override
    public int updateOrders(TOrders tOrders) {
        return tOrdersMapper.updateOrders(tOrders);
    }

    @Override
    public List<TOrders> selectPendingList(TOrders tOrders) {
        return tOrdersMapper.selectPendingList(tOrders);
    }

    @Override
    public List<TOrders> selectOrderReady(TOrders tOrders) {
        return tOrdersMapper.selectOrderReady(tOrders);
    }


}
